home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / asm_reference / asp68k6.txt < prev    next >
Text File  |  1996-01-23  |  54KB  |  1,249 lines

  1.               __
  2.              /_/\__
  3.              \ \ \ |\
  4.               ____\ \ \||__
  5.              / /  \\ \    __/
  6.             | | /\ \\ \ \
  7.             | | \/  \\_\/
  8.          ____\ \  /\ |
  9.         / /  \\ \ \/ |
  10.            | | /\/_\_\__/
  11.            | | \/  \
  12.         ____\ \  /\ |
  13.        / /    \\ \ \/ |       ASP68K PROJECT
  14.       /_/ /\ |\_\__/
  15.       \ \ \/ |        Sixth Edition
  16.        ____\ \    /
  17.       / /  \\ \ \         by Michael Glew
  18.      | | /\/_\ \ \         mglew@laurel.ocs.mq.edu.au
  19.      | | \/  \\_\/         Technophilia BBS +61-2-8073563
  20.   ____\_\__/\ |
  21.  / /  \ /_/\/ |       January 1994
  22. | | /\ \\_\__/
  23. | | \/    \
  24.  \ \  /\ \
  25.   \ \ \_\/
  26.    \ \ \
  27.     \_\/
  28.  
  29.  
  30. ---------------------------------------------------------------------------
  31.               C O N T R I B U T O R S
  32. ---------------------------------------------------------------------------
  33.  
  34.  
  35. Erik Bakke, Robert Barton, Bernd Blank, Kasimir Blomstedt, Frans Bouma,
  36. David Carson, Nicolas Dade, Aaron Digulla, Irmen de Jong, Andy Duplain,
  37. Denis Duplan, Steven Eker, Calle Englund, Alexander Fritsch, Charlie Gibbs,
  38. Kurt Haenen, Jon Hudson, Kjetil Jacobsen, Olav Kalgraf, Makoto Kamada,
  39. Markku Kolkka, John Lane, Jonathan Mahaffy, Dave Mc Mahan, Lindsay Meek,
  40. Walter Misar, Boerge Noest, Gunnar Rxnning, Jay Scott, Olaf Seibert,
  41. Peter Simons.
  42.  
  43.  
  44. ---------------------------------------------------------------------------
  45.               I N T R O D U C T I O N
  46. ---------------------------------------------------------------------------
  47.  
  48.  
  49. A while back, I was quite interested to find that there was an electronic
  50. magazine called "howtocode" that included lots of interesting hints and
  51. tips of coding.  In the fifth edition, there was a list of optimizations
  52. that really got be thinking.  "What if there was a proggy that you could
  53. put an assembler program through, that would speed it up, taking out all
  54. the stupid things output by compilers, and over-tired coders?" 8).  I
  55. started combing the networks, and came across one such program, called
  56. the "SELCO Source Optimizer".  It only had four optimizations, so I set
  57. to writing my own.
  58.  
  59. Step one was to collect as many optimization ideas as I could.  I posted
  60. to Usenet and got an impressive response, and the contributors are listed
  61. above.  I promised a report on the optimizations recieved, and here it
  62. is.  My aim now is to write a program to make these optimizations, and
  63. to distribute it.  Contributers will recieve a copy of the final archive,
  64. to thank them for their time and energy.  Further contributions will be
  65. welcomed, so rather than making changes yourself tell me what you want
  66. changed, and i'll distribute it with the next update.
  67.  
  68.  
  69. ---------------------------------------------------------------------------
  70.                    C H A N G E S
  71. ---------------------------------------------------------------------------
  72.  
  73.  
  74. 2nd Edition
  75.  
  76. The second edition incorporated a hell of a lot of corrections.  Double
  77. copies of some optimizations were incorporated in to just one copy, and
  78. a few additions were made.  Sorry that the first edition was not sent
  79. out to all contributors, but I was a tad busy. 8)
  80.  
  81.  
  82. 3rd Edition
  83.  
  84. Due to the distribution of the second edition document, many comments were
  85. recieved and a couple of the "optimizations" were found to be incorrect.
  86. Analysis of the mul/div optimizations ended in a few modifications for
  87. safety.  They still save a huge number of clock cycles, so it is better to
  88. be safe than sorry.
  89.  
  90. Also, I have made it so that the number of words of space saved or
  91. increased is shown.  Space savings are positive, increases are negative.
  92. Zero means no change.
  93.  
  94.  
  95. 4th Edition
  96.  
  97. Some minor changes and additions as well as the addition of columns for
  98. '030 and '040 CPUs - whole new format was required...
  99.  
  100.  
  101. 5th Edition
  102.  
  103. Eric Bakke released his docs on 020+ CPUs and 881/882 FPUs.  I have been
  104. given premission to use these docs to further the capabilities of asp68k.
  105. Thanks Eric...  I really would like to get a hold of the 020,030,040
  106. Programmer Reference Cards or manuals, so if anyone has any copies they
  107. wanna send me, let me know...  Local Motorola Distributers are not too
  108. helpful.
  109.  
  110.  
  111. 6th Edition
  112.  
  113. Aaron Digulla advised that it would be helpful if the optimizations were
  114. sorted somehow.  I will sort by the the first letters of the first line
  115. of the optimizations.  Also a special thanks to Makoto Kamada for his
  116. detailed contributions, without such this text would have died long ago..
  117.  
  118.  
  119. ---------------------------------------------------------------------------
  120.              O P T I M I Z A T I O N S
  121. ---------------------------------------------------------------------------
  122.  
  123.  
  124. Note:-
  125.  
  126.     m?        = memory operand
  127.     dx        = data register
  128.     ds        = data register (scratch)
  129.     ax        = address register
  130.     rx        = either a data or address register
  131.     #n        = immediate operand
  132.     ??,?1,?2= address label
  133.     *        = anything
  134.     .x        = any size
  135.     b<cc>   = branch commands
  136.  
  137.     Opt     = optimization
  138.     Notes   = notes about where optimization is valid, and misc notes
  139.     Speed   = are clock periods saved? ("Y" = yes
  140.                     "y" = in some cases
  141.                     "N" = no
  142.                     "*" = increase
  143.                     "-" = cannot be used on this cpu
  144.                     "!" = must be used on this cpu)
  145.     Size    = how many bytes are saved?
  146.  
  147. -------------------------------------------------------------
  148. Opt                        Speed     Size
  149.                      000 010 020 030 040
  150. ------------------------------------+---+---+---+---+---+----
  151. * ??* -> * n(pc)*            | Y | Y | ? | ? | ? | 2
  152. ------------------------------------+---+---+---+---+---+----
  153.  n = ??-pc, n < 32768
  154. ------------------------------------+---+---+---+---+---+----
  155. *0(ax)* -> *(ax)*            | Y | Y | ? | ? | ? | 2
  156. ------------------------------------+---+---+---+---+---+----
  157. add*.x #0,dx -> tst.x dx        | Y | Y | ? | ? | ? | 2/4
  158. ------------------------------------+---+---+---+---+---+----
  159. add.x #n,* -> addq.x #n,*        | Y | Y | ? | ? | ? | 2/4
  160. ------------------------------------+---+---+---+---+---+----
  161.  if 1 <= n <= 8
  162. ------------------------------------+---+---+---+---+---+----
  163. add.x #n,* -> subq.x #-n,*        | Y | Y | ? | ? | ? | 2/4
  164. ------------------------------------+---+---+---+---+---+----
  165.  -8 <= n <= -1
  166. ------------------------------------+---+---+---+---+---+----
  167. add.x #n,ax -> lea n(ax),ax        | Y | Y | ? | ? | ? | 0/2
  168. ------------------------------------+---+---+---+---+---+----
  169.  -32767 <= n <= -9, 9 <= n <= 32767
  170. ------------------------------------+---+---+---+---+---+----
  171. addq.l #n,ax -> addq.w #n,ax        | Y | Y | ? | ? | ? | 0
  172. ------------------------------------+---+---+---+---+---+----
  173. addq.l #n,ry -> add.l #(n+m),ry     | Y | Y | ? | ? | ? | -2
  174. addq.l #m,ry                |    |   |    |   |    |
  175. ------------------------------------+---+---+---+---+---+----
  176. addq.x #2,ax   -> move.w *,(ax)     | Y | Y | ? | Y | ? | 2
  177. move.w *,-(ax)                      |   |   |   |   |   |
  178. ------------------------------------+---+---+---+---+---+----
  179.  .x is .w or .l
  180. ------------------------------------+---+---+---+---+---+----
  181. addq.x #4,ax   -> move.l *,(ax)     | Y | Y | ? | Y | ? | 2
  182. move.l *,-(ax)                      |   |   |   |   |   |
  183. ------------------------------------+---+---+---+---+---+----
  184.  .x is .w or .l
  185. ------------------------------------+---+---+---+---+---+----
  186. addq.x #6,ax    -> move.w *1,4(ax)  | Y | Y | ? | ? | ? | 0
  187. move.w *1,-(ax)    move.l *2,(ax)   |   |   |   |   |   |
  188. move.l *2,-(ax)                     |   |   |   |   |   |
  189. ------------------------------------+---+---+---+---+---+----
  190.  .x is .w or .l
  191.  *1 and *2 do not contain ax
  192. ------------------------------------+---+---+---+---+---+----
  193. addq.x #6,ax    -> move.l *1,2(ax)  | Y | Y | ? | ? | ? | 0
  194. move.l *1,-(ax)    move.w *2,(ax)   |   |   |   |   |   |
  195. move.w *2,-(ax)                     |   |   |   |   |   |
  196. ------------------------------------+---+---+---+---+---+----
  197.  .x is .w or .l
  198.  *1 and *2 do not contain ax
  199. ------------------------------------+---+---+---+---+---+----
  200. addq.x #8,ax    -> move.l *1,4(ax)  | Y | Y | ? | ? | ? | 0
  201. move.l *1,-(ax)    move.l *2,(ax)   |   |   |   |   |   |
  202. move.l *2,-(ax)                     |   |   |   |   |   |
  203. ------------------------------------+---+---+---+---+---+----
  204.  .x is .w or .l
  205.  *1 and *2 do not contain ax
  206. ------------------------------------+---+---+---+---+---+----
  207. addq.x #4,sp -> move.l ax,(sp)      | Y | Y | ? | Y | ? | 2
  208. pea (ax)                            |   |   |   |   |   |
  209. ------------------------------------+---+---+---+---+---+----
  210.  .x is .w or .l
  211.  ax,ay are not a7(=sp)
  212. ------------------------------------+---+---+---+---+---+----
  213. addq.x #6,sp   -> move.w *,4(sp)    | Y | Y | ? | ? | ? | 0
  214. move.w *,-(sp)    move.l ax,(sp)    |   |   |   |   |   |
  215. pea (ax)                            |   |   |   |   |   |
  216. ------------------------------------+---+---+---+---+---+----
  217.  .x is .w or .l
  218.  ax,ay are not a7(=sp)
  219. ------------------------------------+---+---+---+---+---+----
  220. addq.x #6,sp   -> move.l ax,2(sp)   | Y | Y | ? | ? | ? | 0
  221. pea (ax)          move.w *,(sp)     |   |   |   |   |   |
  222. move.w *,-(sp)                      |   |   |   |   |   |
  223. ------------------------------------+---+---+---+---+---+----
  224.  .x is .w or .l
  225.  ax,ay are not a7(=sp)
  226. ------------------------------------+---+---+---+---+---+----
  227. addq.x #8,sp   -> move.l *,4(sp)    | Y | Y | ? | ? | ? | 0
  228. move.l *,-(sp)    move.l ax,(sp)    |   |   |   |   |   |
  229. pea (ax)                            |   |   |   |   |   |
  230. ------------------------------------+---+---+---+---+---+----
  231.  .x is .w or .l
  232.  ax,ay are not a7(=sp)
  233. ------------------------------------+---+---+---+---+---+----
  234. addq.x #8,sp   -> move.l ax,4(sp)   | Y | Y | ? | ? | ? | 0
  235. pea (ax)          move.l *,(sp)     |   |   |   |   |   |
  236. move.l *,-(sp)                      |   |   |   |   |   |
  237. ------------------------------------+---+---+---+---+---+----
  238.  .x is .w or .l
  239.  ax,ay are not a7(=sp)
  240. ------------------------------------+---+---+---+---+---+----
  241. addq.x #8,sp -> move.l ax,4(sp)     | Y | Y | ? | ? | ? | 0
  242. pea (ax)        move.l ay,(sp)      |   |   |   |   |   |
  243. pea (ay)                            |   |   |   |   |   |
  244. ------------------------------------+---+---+---+---+---+----
  245.  .x is .w or .l
  246.  ax,ay are not a7(=sp)
  247. ------------------------------------+---+---+---+---+---+----
  248. and.l #n,dx -> bclr.l #b,dx        | Y | Y | ? | ? | ? | 2
  249. ------------------------------------+---+---+---+---+---+----
  250. not(n) = 2^b (only 1 bit off)
  251. ------------------------------------+---+---+---+---+---+----
  252. asl.b #2,dy -> add.b dy,dy        | Y | Y | ? | ? | ? | -2
  253.            add.b dy,dy        |    |   |    |   |    |
  254. ------------------------------------+---+---+---+---+---+----
  255. asl.b #n,dx -> clr.b dx         | Y | Y | ? | ? | ? | 0
  256. ------------------------------------+---+---+---+---+---+----
  257.  status flags are wrong, n>=8
  258. ------------------------------------+---+---+---+---+---+----
  259. asl.l #16,dx -> swap dx         | Y | Y | ? | ? | ? | -2
  260.         clr.w dx        |    |   |    |   |    |
  261. ------------------------------------+---+---+---+---+---+----
  262.  status flags are wrong
  263. ------------------------------------+---+---+---+---+---+----
  264. asl.l #n,dx -> asl.w #(n-16),dx     | Y | Y | ? | ? | ? | -4
  265.            swap dx            |    |   |    |   |    |
  266.            clr.w dx         |    |   |    |   |    |
  267. ------------------------------------+---+---+---+---+---+----
  268.  status flags are wrong, 16<n<32
  269. ------------------------------------+---+---+---+---+---+----
  270. asl.l #n,dx -> moveq #0,dx        | Y | Y | ? | ? | ? | 0
  271. ------------------------------------+---+---+---+---+---+----
  272.  status flags are wrong, n>=32
  273. ------------------------------------+---+---+---+---+---+----
  274. asl.w #2,dy -> add.w dy,dy        | Y | Y | ? | ? | ? | -2
  275.            add.w dy,dy        |    |   |    |   |    |
  276. ------------------------------------+---+---+---+---+---+----
  277. asl.w #n,dx -> clr.w dx         | Y | Y | ? | ? | ? | 0
  278. ------------------------------------+---+---+---+---+---+----
  279.  status flags are wrong, n>=16
  280. ------------------------------------+---+---+---+---+---+----
  281. asl.x #1,dy -> add.x dy,dy        | Y | Y | ? | ? | ? | 0
  282. ------------------------------------+---+---+---+---+---+----
  283. asr.b #n,dx -> clr.b dx         | Y | Y | ? | ? | ? | 0
  284. ------------------------------------+---+---+---+---+---+----
  285.  status flags are wrong, n>=8
  286. ------------------------------------+---+---+---+---+---+----
  287. asr.l #16,dx -> swap dx         | Y | Y | ? | ? | ? | -2
  288.         ext.l dx        |    |   |    |   |    |
  289. ------------------------------------+---+---+---+---+---+----
  290.  status flags are wrong
  291. ------------------------------------+---+---+---+---+---+----
  292. asr.l #n,dx -> moveq #0,dx        | Y | Y | ? | ? | ? | 0
  293. ------------------------------------+---+---+---+---+---+----
  294.  status flags are wrong, n>=32
  295. ------------------------------------+---+---+---+---+---+----
  296. asr.l #n,dx -> swap dx            | Y | Y | ? | ? | ? | -4
  297.            asr.w #(n-16),dx     |    |   |    |   |    |
  298.            ext.l dx         |    |   |    |   |    |
  299. ------------------------------------+---+---+---+---+---+----
  300.  status flags are wrong, 16<n<32
  301. ------------------------------------+---+---+---+---+---+----
  302. asr.w #n,dx -> clr.w dx         | Y | Y | ? | ? | ? | 0
  303. ------------------------------------+---+---+---+---+---+----
  304.  status flags are wrong, n>=16
  305. ------------------------------------+---+---+---+---+---+----
  306. b<cc>.w ?? -> b<cc>.s ??        | Y | Y | ? | ? | ? | 2
  307. ------------------------------------+---+---+---+---+---+----
  308.  abs(??-pc)<128
  309. ------------------------------------+---+---+---+---+---+----
  310. bclr.l #n,dx -> and.w #m,dx         | Y | Y | ? | Y | ? | 0
  311. ------------------------------------+---+---+---+---+---+----
  312.  0 <= n <= 15, m = 65535-(2^n)
  313.  status flags are wrong
  314. ------------------------------------+---+---+---+---+---+----
  315. bra ?? -> (nothing)            | Y | Y | Y | ? | ? | 2/4
  316. ??      ??                |    |   |    |   |    |
  317. ------------------------------------+---+---+---+---+---+----
  318.  remove null branches, but keep the label
  319. ------------------------------------+---+---+---+---+---+----
  320. bset.b #7,m? -> tas m?              | y | y | ? | ? | ? | 2
  321. beq ??          bpl ??              |   |   |   |   |   |
  322. ------------------------------------+---+---+---+---+---+----
  323.  m? must be address allowing read-modify-write transfer.
  324.  Status flags are wrong
  325. ------------------------------------+---+---+---+---+---+----
  326. bset.b #7,m? -> tas m?              | y | y | ? | ? | ? | 2
  327. bne ??          bmi ??              |   |   |   |   |   |
  328. ------------------------------------+---+---+---+---+---+----
  329.  m? must be address allowing read-modify-write transfer.
  330.  Status flags are wrong
  331. ------------------------------------+---+---+---+---+---+----
  332. bset.b #7,m? -> tas m?              | y | y | ? | ? | ? | 2
  333. ------------------------------------+---+---+---+---+---+----
  334.  m? must be address allowing read-modify-write transfer.
  335.  Status flags are wrong
  336. ------------------------------------+---+---+---+---+---+----
  337. bset.l #7,dx -> tas dx              | Y | Y | ? | Y | ? | 2
  338. beq ??          bpl ??              |   |   |   |   |   |
  339. ------------------------------------+---+---+---+---+---+----
  340.  status flags are wrong
  341. ------------------------------------+---+---+---+---+---+----
  342. bset.l #7,dx -> tas dx              | Y | Y | ? | Y | ? | 2
  343. bne ??          bmi ??              |   |   |   |   |   |
  344. ------------------------------------+---+---+---+---+---+----
  345.  status flags are wrong
  346. ------------------------------------+---+---+---+---+---+----
  347. bset.l #7,dx -> tas dx              | Y | Y | ? | Y | ? | 2
  348. ------------------------------------+---+---+---+---+---+----
  349.  status flags are wrong
  350. ------------------------------------+---+---+---+---+---+----
  351. bset.l #n,dx -> or.w #m,dx          | Y | Y | ? | Y | ? | 0
  352. ------------------------------------+---+---+---+---+---+----
  353.  0 <= n <= 15, m = 2^n
  354.  status flags are wrong
  355. ------------------------------------+---+---+---+---+---+----
  356. bsr ?? -> bra ??            | Y | Y | ? | ? | ? | 2
  357. rts                    |    |   |    |   |    |
  358. ------------------------------------+---+---+---+---+---+----
  359.  different stack depth
  360. ------------------------------------+---+---+---+---+---+----
  361. btst.b #7,m? -> tst.b m?            | Y | Y | ? | ? | ? | 2
  362. beq ??          bpl ??              |   |   |   |   |   |
  363. ------------------------------------+---+---+---+---+---+----
  364.  Status flags are wrong.  Not valid for Dn, d16(PC), d8(PC,Xn)
  365.  dest address modes.
  366. ------------------------------------+---+---+---+---+---+----
  367. btst.b #7,m? -> tst.b m?            | Y | Y | ? | ? | ? | 2
  368. bne ??          bmi ??              |   |   |   |   |   |
  369. ------------------------------------+---+---+---+---+---+----
  370.  Status flags are wrong.  Not valid for Dn, d16(PC), d8(PC,Xn)
  371.  dest address modes.
  372. ------------------------------------+---+---+---+---+---+----
  373. btst.l #7,dx -> tst.b dx            | Y | Y | ? | Y | ? | 2
  374. beq ??          bpl ??              |   |   |   |   |   |
  375. ------------------------------------+---+---+---+---+---+----
  376.  Status flags are wrong.
  377. ------------------------------------+---+---+---+---+---+----
  378. btst.l #7,dx -> tst.b dx            | Y | Y | ? | Y | ? | 2
  379. bne ??          bmi ??              |   |   |   |   |   |
  380. ------------------------------------+---+---+---+---+---+----
  381.  Status flags are wrong.
  382. ------------------------------------+---+---+---+---+---+----
  383. btst.l #15,dx -> tst.w dx           | Y | Y | ? | Y | ? | 2
  384. beq ??           bpl ??             |   |   |   |   |   |
  385. ------------------------------------+---+---+---+---+---+----
  386.  Status flags are wrong.
  387. ------------------------------------+---+---+---+---+---+----
  388. btst.l #15,dx -> tst.w dx           | Y | Y | ? | Y | ? | 2
  389. bne ??           bmi ??             |   |   |   |   |   |
  390. ------------------------------------+---+---+---+---+---+----
  391.  Status flags are wrong.
  392. ------------------------------------+---+---+---+---+---+----
  393. btst.l #31,dx -> tst.l dx           | Y | Y | ? | Y | ? | 2
  394. beq ??           bpl ??             |   |   |   |   |   |
  395. ------------------------------------+---+---+---+---+---+----
  396.  Status flags are wrong.
  397. ------------------------------------+---+---+---+---+---+----
  398. btst.l #31,dx -> tst.l dx           | Y | Y | ? | Y | ? | 2
  399. bne ??           bmi ??             |   |   |   |   |   |
  400. ------------------------------------+---+---+---+---+---+----
  401.  status flags are wrong
  402. ------------------------------------+---+---+---+---+---+----
  403. clr.b mn   -> clr.w mn            | Y | Y | ? | ? | ? | 2/4/6
  404. clr.b mn+1                |    |   |    |   |    |
  405. ------------------------------------+---+---+---+---+---+----
  406.  best if mn is longword aligned
  407. ------------------------------------+---+---+---+---+---+----
  408. clr.l dx -> moveq #0,dx         | Y | Y | ? | ? | ? | 0
  409. ------------------------------------+---+---+---+---+---+----
  410. clr.w mn   -> clr.l mn            | Y | Y | ? | ? | ? | 2/4/6
  411. clr.w mn+2                |    |   |    |   |    |
  412. ------------------------------------+---+---+---+---+---+----
  413.  best if mn is longword aligned
  414. ------------------------------------+---+---+---+---+---+----
  415. clr.x -(ax) -> move.x ds,-(ax)        | Y | Y | ? | ? | ? | 0
  416. ------------------------------------+---+---+---+---+---+----
  417.  ds must equal zero
  418. ------------------------------------+---+---+---+---+---+----
  419. clr.x n(ax,rx) -> move.x ds,n(ax,rx)| Y | Y | ? | ? | ? | 0
  420. ------------------------------------+---+---+---+---+---+----
  421.  ds must equal zero
  422. ------------------------------------+---+---+---+---+---+----
  423. cmp.x #0,ax -> move.x ax,ds        | Y | Y | ? | ? | ? | 2/4
  424. ------------------------------------+---+---+---+---+---+----
  425.  move ax to scratch register
  426. ------------------------------------+---+---+---+---+---+----
  427. cmp.x #0,ax -> tst.x ax             | - | - | ? | ? | ? | ?
  428. ------------------------------------+---+---+---+---+---+----
  429. for .w and .l
  430. ------------------------------------+---+---+---+---+---+----
  431. cmp.x #0,dx -> tst.x dx         | Y | Y | ? | ? | ? | 2/4
  432. ------------------------------------+---+---+---+---+---+----
  433. cmp.x #0,m? -> tst.x m?         | Y | Y | ? | ? | ? | 2/4
  434. ------------------------------------+---+---+---+---+---+----
  435. may not be legal on some early '000 CPUs
  436. ------------------------------------+---+---+---+---+---+----
  437. divu.l #n,dx -> lsr.l #m,dx        | ! | ! | ? | ? | ? | 4
  438. ------------------------------------+---+---+---+---+---+----
  439.  n is 2^m, 1 <= m <= 8
  440. ------------------------------------+---+---+---+---+---+----
  441. divu.l #n,dx -> moveq #0,dx        | ! | ! | ? | ? | ? | 4
  442. ------------------------------------+---+---+---+---+---+----
  443.  n is 2^m, m>=32
  444. ------------------------------------+---+---+---+---+---+----
  445. divu.l #n,dx -> moveq #m,ds        | ! | ! | ? | ? | ? | 2
  446.         lsr.l ds,dx        |    |   |    |   |    |
  447. ------------------------------------+---+---+---+---+---+----
  448.  n is 2^m, 8<m<32
  449. ------------------------------------+---+---+---+---+---+----
  450. divu.w #n,dx -> lsr.l #m,dx        | Y | Y | ? | ? | ? | 2
  451. ------------------------------------+---+---+---+---+---+----
  452.  n is 2^m, 1 <= m <= 8, ignore remainder
  453. ------------------------------------+---+---+---+---+---+----
  454. divu.w #n,dx -> moveq #0,dx        | Y | Y | ? | ? | ? | 2
  455. ------------------------------------+---+---+---+---+---+----
  456.  n is 2^m, m>=32
  457. ------------------------------------+---+---+---+---+---+----
  458. divu.w #n,dx -> moveq #m,ds        | Y | Y | ? | ? | ? | 0
  459.         lsr.l ds,dx        |    |   |    |   |    |
  460. ------------------------------------+---+---+---+---+---+----
  461.  n is 2^m, 8<m<32, ignore remainder
  462. ------------------------------------+---+---+---+---+---+----
  463. eor.x #-1,* -> not.x *            | Y | Y | ? | ? | ? | 2/4
  464. ------------------------------------+---+---+---+---+---+----
  465. ext.w dx -> extb.l dx            | - | - | ? | ? | ? | 2
  466. ext.l dx                |    |   |    |   |    |
  467. ------------------------------------+---+---+---+---+---+----
  468. jmp ?? -> bra.w ??            | Y | Y | ? | ? | ? | 2
  469. ------------------------------------+---+---+---+---+---+----
  470.  abs(??-pc) < 32768, same section
  471. ------------------------------------+---+---+---+---+---+----
  472. jsr * -> jmp *                | Y | Y | ? | ? | ? | 2
  473. rts                    |    |   |    |   |    |
  474. ------------------------------------+---+---+---+---+---+----
  475.  different stack depth
  476. ------------------------------------+---+---+---+---+---+----
  477. jsr ?1 -> pea ?2            | y | y | ? | ? | ? | 0
  478. jmp ?2    jmp ?1            |    |   |    |   |    |
  479. ------------------------------------+---+---+---+---+---+----
  480.  same time if jsr is abs.l
  481. ------------------------------------+---+---+---+---+---+----
  482. jsr ?? -> bsr.w ??            | Y | Y | ? | ? | ? | 2
  483. ------------------------------------+---+---+---+---+---+----
  484.  abs(??-pc) < 32768, same section
  485. ------------------------------------+---+---+---+---+---+----
  486. lea (ax),ax -> (nothing)        | Y | Y | Y | ? | ? | 2
  487. ------------------------------------+---+---+---+---+---+----
  488.  delete
  489. ------------------------------------+---+---+---+---+---+----
  490. lea 0.w,ax -> sub.l ax,ax        | Y | Y | - | - | - | 2
  491. ------------------------------------+---+---+---+---+---+----
  492. lea n(ax),ax -> addq.w #n,ax        | Y | Y | ? | ? | ? | 2
  493. ------------------------------------+---+---+---+---+---+----
  494.  if 1 <= n <= 8
  495. ------------------------------------+---+---+---+---+---+----
  496. lea n(ax),ax -> subq.w #-n,ax        | Y | Y | ? | ? | ? | 2
  497. ------------------------------------+---+---+---+---+---+----
  498.  if -8 <= n <= -1
  499. ------------------------------------+---+---+---+---+---+----
  500. lsl.b #2,dy -> add.b dy,dy        | Y | Y | ? | ? | ? | -2
  501.            add.b dy,dy        |    |   |    |   |    |
  502. ------------------------------------+---+---+---+---+---+----
  503. lsl.b #n,dx -> clr.b dx         | Y | Y | ? | ? | ? | 0
  504. ------------------------------------+---+---+---+---+---+----
  505.  status flags are wrong, n>=8
  506. ------------------------------------+---+---+---+---+---+----
  507. lsl.l #16,dx -> swap dx         | Y | Y | ? | ? | ? | -2
  508.         clr.w dx        |    |   |    |   |    |
  509. ------------------------------------+---+---+---+---+---+----
  510.  status flags are wrong
  511. ------------------------------------+---+---+---+---+---+----
  512. lsl.l #n,dx -> lsl.w #(n-16),dx     | Y | Y | ? | ? | ? | -4
  513.            swap dx            |    |   |    |   |    |
  514.            clr.w dx         |    |   |    |   |    |
  515. ------------------------------------+---+---+---+---+---+----
  516.  status flags are wrong, 16<n<32
  517. ------------------------------------+---+---+---+---+---+----
  518. lsl.l #n,dx -> moveq #0,dx        | Y | Y | ? | ? | ? | 0
  519. ------------------------------------+---+---+---+---+---+----
  520.  status flags are wrong, n>=32
  521. ------------------------------------+---+---+---+---+---+----
  522. lsl.w #2,dy -> add.w dy,dy        | Y | Y | ? | ? | ? | -2
  523.            add.w dy,dy        |    |   |    |   |    |
  524. ------------------------------------+---+---+---+---+---+----
  525. lsl.w #n,dx -> clr.w dx         | Y | Y | ? | ? | ? | 0
  526. ------------------------------------+---+---+---+---+---+----
  527.  status flags are wrong, n>=16
  528. ------------------------------------+---+---+---+---+---+----
  529. lsl.x #1,dy -> add.x dy,dy        | Y | Y | ? | ? | ? | 0
  530. ------------------------------------+---+---+---+---+---+----
  531. lsr.b #n,dx -> clr.b dx         | Y | Y | ? | ? | ? | 0
  532. ------------------------------------+---+---+---+---+---+----
  533.  status flags are wrong, n>=8
  534. ------------------------------------+---+---+---+---+---+----
  535. lsr.l #16,dx -> clr.w dx        | Y | Y | ? | ? | ? | -2
  536.         swap dx         |    |   |    |   |    |
  537. ------------------------------------+---+---+---+---+---+----
  538.  status flags are wrong
  539. ------------------------------------+---+---+---+---+---+----
  540. lsr.l #n,dx -> clr.w dx         | Y | Y | ? | ? | ? | -4
  541.            swap dx            |    |   |    |   |    |
  542.            lsr.w #(n-16),dx     |    |   |    |   |    |
  543. ------------------------------------+---+---+---+---+---+----
  544.  status flags are wrong, 16<n<32
  545. ------------------------------------+---+---+---+---+---+----
  546. lsr.l #n,dx -> moveq #0,dx        | Y | Y | ? | ? | ? | 0
  547. ------------------------------------+---+---+---+---+---+----
  548.  status flags are wrong, n>=32
  549. ------------------------------------+---+---+---+---+---+----
  550. lsr.w #n,dx -> clr.w dx         | Y | Y | ? | ? | ? | 0
  551. ------------------------------------+---+---+---+---+---+----
  552.  status flags are wrong, n>=16
  553. ------------------------------------+---+---+---+---+---+----
  554. move.b #-1,(ax) -> st (ax)        | Y | Y | ? | ? | ? | 2
  555. ------------------------------------+---+---+---+---+---+----
  556.  status flags are wrong
  557. ------------------------------------+---+---+---+---+---+----
  558. move.b #-1,(ax)+ -> st (ax)+        | N | N | ? | ? | ? | 2
  559. ------------------------------------+---+---+---+---+---+----
  560.  status flags are wrong
  561. ------------------------------------+---+---+---+---+---+----
  562. move.b #-1,-(ax) -> st -(ax)        | N | N | ? | ? | ? | 2
  563. ------------------------------------+---+---+---+---+---+----
  564.  status flags are wrong
  565. ------------------------------------+---+---+---+---+---+----
  566. move.b #-1,?? -> st ??            | Y | Y | ? | ? | ? | 2
  567. ------------------------------------+---+---+---+---+---+----
  568.  status flags are wrong
  569. ------------------------------------+---+---+---+---+---+----
  570. move.b #-1,dx -> st dx            | Y | Y | ? | ? | ? | 2
  571. ------------------------------------+---+---+---+---+---+----
  572.  status flags are wrong
  573. ------------------------------------+---+---+---+---+---+----
  574. move.b #-1,n(ax) -> st n(ax)        | Y | Y | ? | ? | ? | 2
  575. ------------------------------------+---+---+---+---+---+----
  576.  status flags are wrong
  577. ------------------------------------+---+---+---+---+---+----
  578. move.b #-1,n(ax,rx) -> st n(ax,rx)  | Y | Y | ? | ? | ? | 2
  579. ------------------------------------+---+---+---+---+---+----
  580.  status flags are wrong
  581. ------------------------------------+---+---+---+---+---+----
  582. move.b #x,mn   -> move.w #xy,mn     | Y | Y | ? | ? | ? | 4/6/8
  583. move.b #y,mn+1                |    |   |    |   |    |
  584. ------------------------------------+---+---+---+---+---+----
  585.  best if mn is longword aligned
  586. ------------------------------------+---+---+---+---+---+----
  587. move.l #n,-(sp) -> pea n.w        | Y | Y | ? | ? | ? | 2
  588. ------------------------------------+---+---+---+---+---+----
  589.  -32767 <= n <= 32767
  590. ------------------------------------+---+---+---+---+---+----
  591. move.l #n,ax -> move.w #n,ax        | Y | Y | ? | ? | ? | 2
  592. ------------------------------------+---+---+---+---+---+----
  593.  -32767 <= n <= 32767
  594. ------------------------------------+---+---+---+---+---+----
  595. move.l #n,dx -> moveq #-128,dx        | Y | Y | ? | N | * | 2
  596.         subq.l #n+128,dx    |    |   |    |   |    |
  597. ------------------------------------+---+---+---+---+---+----
  598.  -136 <= n <= -129
  599. ------------------------------------+---+---+---+---+---+----
  600. move.l #n,dx -> moveq #m,dx        | Y | Y | ? | ? | ? | 2
  601.         not.b dx        |    |   |    |   |    |
  602. ------------------------------------+---+---+---+---+---+----
  603.  128 <= n <= 255, m = 255-n
  604. ------------------------------------+---+---+---+---+---+----
  605. move.l #n,dx -> moveq #m,dx        | Y | Y | ? | ? | ? | 2
  606.         not.w dx        |    |   |    |   |    |
  607.                     |    |   |    |   |    |
  608. ------------------------------------+---+---+---+---+---+----
  609.  65534 <= n <= 65408 or -65409 <= n <= -65536, m = 65535-abs(n)
  610. ------------------------------------+---+---+---+---+---+----
  611. move.l #n,dx -> moveq #m,dx        | Y | Y | ? | ? | ? | 2
  612.         swap dx         |    |   |    |   |    |
  613.                     |    |   |    |   |    |
  614. ------------------------------------+---+---+---+---+---+----
  615.  -8323073 <= n <= -65537 or 4096 <= n <= 8323072, n = m*65536
  616. ------------------------------------+---+---+---+---+---+----
  617. move.l #n,dx -> moveq #n,dx        | Y | Y | ? | ? | ? | 4
  618. ------------------------------------+---+---+---+---+---+----
  619.  if -128 <= n <= 127
  620. ------------------------------------+---+---+---+---+---+----
  621. move.l #n,dx -> moveq #y,dx        | * | * | ? | ? | ? | 2
  622.         lsl.l #z,dx        |    |   |    |   |    |
  623. ------------------------------------+---+---+---+---+---+----
  624.  n = y * 2^z
  625. ------------------------------------+---+---+---+---+---+----
  626. move.l #n,dx -> moveq #m,dx         | Y | Y | ? | N | ? | 2
  627.                 add.b dx,dx         |   |   |   |   |   |
  628. ------------------------------------+---+---+---+---+---+----
  629.  (128 <= n <= 254 or -256 <= n <= -130) and n is even, m = n/2
  630. ------------------------------------+---+---+---+---+---+----
  631. move.l #n,dx -> moveq #m,dx         | Y | Y | ? | * | ? | 2
  632.                 bchg.l dx,dx        |   |   |   |   |   |
  633. ------------------------------------+---+---+---+---+---+----
  634.  n = -32881 -> m = -113
  635.  n = -32849 -> m = -81
  636.  n = -32817 -> m = -49
  637.  n = -32785 -> m = -17
  638.  n = -16498 -> m = -114
  639.  n = -16466 -> m = -82
  640.  n = -16434 -> m = -50
  641.  n = -16402 -> m = -18
  642.  n = -8307 -> m = -115
  643.  n = -8275 -> m = -83
  644.  n = -8243 -> m = -51
  645.  n = -8211 -> m = -19
  646.  n = -4212 -> m = -116
  647.  n = -4180 -> m = -84
  648.  n = -4148 -> m = -52
  649.  n = -4116 -> m = -20
  650.  n = -2165 -> m = -117
  651.  n = -2133 -> m = -85
  652.  n = -2101 -> m = -53
  653.  n = -2069 -> m = -21
  654.  n = -1142 -> m = -118
  655.  n = -1110 -> m = -86
  656.  n = -1078 -> m = -54
  657.  n = -1046 -> m = -22
  658.  n = -631 -> m = -119
  659.  n = -599 -> m = -87
  660.  n = -567 -> m = -55
  661.  n = -535 -> m = -23
  662.  n = -376 -> m = -120
  663.  n = -344 -> m = -88
  664.  n = -312 -> m = -56
  665.  n = -280 -> m = -24
  666.  n = 264 -> m = 8
  667.  n = 296 -> m = 40
  668.  n = 328 -> m = 72
  669.  n = 360 -> m = 104
  670.  n = 521 -> m = 9
  671.  n = 553 -> m = 41
  672.  n = 585 -> m = 73
  673.  n = 617 -> m = 105
  674.  n = 1034 -> m = 10
  675.  n = 1066 -> m = 42
  676.  n = 1098 -> m = 74
  677.  n = 1130 -> m = 106
  678.  n = 2059 -> m = 11
  679.  n = 2091 -> m = 43
  680.  n = 2123 -> m = 75
  681.  n = 2155 -> m = 107
  682.  n = 4108 -> m = 12
  683.  n = 4140 -> m = 44
  684.  n = 4172 -> m = 76
  685.  n = 4204 -> m = 108
  686.  n = 8205 -> m = 13
  687.  n = 8237 -> m = 45
  688.  n = 8269 -> m = 77
  689.  n = 8301 -> m = 109
  690.  n = 16398 -> m = 14
  691.  n = 16430 -> m = 46
  692.  n = 16462 -> m = 78
  693.  n = 16494 -> m = 110
  694.  n = 32783 -> m = 15
  695.  n = 32815 -> m = 47
  696.  n = 32847 -> m = 79
  697.  n = 32879 -> m = 111
  698. ------------------------------------+---+---+---+---+---+----
  699. move.l #n,dx -> moveq #m,dx         | N | N | ? | * | ? | 2
  700.                 bchg.l dx,dx        |   |   |   |   |   |
  701. ------------------------------------+---+---+---+---+---+----
  702.  n = -2147483617 -> m = 31
  703.  n = -2147483585 -> m = 63
  704.  n = -2147483553 -> m = 95
  705.  n = -2147483521 -> m = 127
  706.  n = -1073741922 -> m = -98
  707.  n = -1073741890 -> m = -66
  708.  n = -1073741858 -> m = -34
  709.  n = -1073741826 -> m = -2
  710.  n = -536871011 -> m = -99
  711.  n = -536870979 -> m = -67
  712.  n = -536870947 -> m = -35
  713.  n = -536870915 -> m = -3
  714.  n = -268435556 -> m = -100
  715.  n = -268435524 -> m = -68
  716.  n = -268435492 -> m = -36
  717.  n = -268435460 -> m = -4
  718.  n = -134217829 -> m = -101
  719.  n = -134217797 -> m = -69
  720.  n = -134217765 -> m = -37
  721.  n = -134217733 -> m = -5
  722.  n = -67108966 -> m = -102
  723.  n = -67108934 -> m = -70
  724.  n = -67108902 -> m = -38
  725.  n = -67108870 -> m = -6
  726.  n = -33554535 -> m = -103
  727.  n = -33554503 -> m = -71
  728.  n = -33554471 -> m = -39
  729.  n = -33554439 -> m = -7
  730.  n = -16777320 -> m = -104
  731.  n = -16777288 -> m = -72
  732.  n = -16777256 -> m = -40
  733.  n = -16777224 -> m = -8
  734.  n = -8388713 -> m = -105
  735.  n = -8388681 -> m = -73
  736.  n = -8388649 -> m = -41
  737.  n = -8388617 -> m = -9
  738.  n = -4194410 -> m = -106
  739.  n = -4194378 -> m = -74
  740.  n = -4194346 -> m = -42
  741.  n = -4194314 -> m = -10
  742.  n = -2097259 -> m = -107
  743.  n = -2097227 -> m = -75
  744.  n = -2097195 -> m = -43
  745.  n = -2097163 -> m = -11
  746.  n = -1048684 -> m = -108
  747.  n = -1048652 -> m = -76
  748.  n = -1048620 -> m = -44
  749.  n = -1048588 -> m = -12
  750.  n = -524397 -> m = -109
  751.  n = -524365 -> m = -77
  752.  n = -524333 -> m = -45
  753.  n = -524301 -> m = -13
  754.  n = -262254 -> m = -110
  755.  n = -262222 -> m = -78
  756.  n = -262190 -> m = -46
  757.  n = -262158 -> m = -14
  758.  n = -131183 -> m = -111
  759.  n = -131151 -> m = -79
  760.  n = -131119 -> m = -47
  761.  n = -131087 -> m = -15
  762.  n = -65648 -> m = -112
  763.  n = -65616 -> m = -80
  764.  n = -65584 -> m = -48
  765.  n = -65552 -> m = -16
  766.  n = 65552 -> m = 16
  767.  n = 65584 -> m = 48
  768.  n = 65616 -> m = 80
  769.  n = 65648 -> m = 112
  770.  n = 131089 -> m = 17
  771.  n = 131121 -> m = 49
  772.  n = 131153 -> m = 81
  773.  n = 131185 -> m = 113
  774.  n = 262162 -> m = 18
  775.  n = 262194 -> m = 50
  776.  n = 262226 -> m = 82
  777.  n = 262258 -> m = 114
  778.  n = 524307 -> m = 19
  779.  n = 524339 -> m = 51
  780.  n = 524371 -> m = 83
  781.  n = 524403 -> m = 115
  782.  n = 1048596 -> m = 20
  783.  n = 1048628 -> m = 52
  784.  n = 1048660 -> m = 84
  785.  n = 1048692 -> m = 116
  786.  n = 2097173 -> m = 21
  787.  n = 2097205 -> m = 53
  788.  n = 2097237 -> m = 85
  789.  n = 2097269 -> m = 117
  790.  n = 4194326 -> m = 22
  791.  n = 4194358 -> m = 54
  792.  n = 4194390 -> m = 86
  793.  n = 4194422 -> m = 118
  794.  n = 8388631 -> m = 23
  795.  n = 8388663 -> m = 55
  796.  n = 8388695 -> m = 87
  797.  n = 8388727 -> m = 119
  798.  n = 16777240 -> m = 24
  799.  n = 16777272 -> m = 56
  800.  n = 16777304 -> m = 88
  801.  n = 16777336 -> m = 120
  802.  n = 33554457 -> m = 25
  803.  n = 33554489 -> m = 57
  804.  n = 33554521 -> m = 89
  805.  n = 33554553 -> m = 121
  806.  n = 67108890 -> m = 26
  807.  n = 67108922 -> m = 58
  808.  n = 67108954 -> m = 90
  809.  n = 67108986 -> m = 122
  810.  n = 134217755 -> m = 27
  811.  n = 134217787 -> m = 59
  812.  n = 134217819 -> m = 91
  813.  n = 134217851 -> m = 123
  814.  n = 268435484 -> m = 28
  815.  n = 268435516 -> m = 60
  816.  n = 268435548 -> m = 92
  817.  n = 268435580 -> m = 124
  818.  n = 536870941 -> m = 29
  819.  n = 536870973 -> m = 61
  820.  n = 536871005 -> m = 93
  821.  n = 536871037 -> m = 125
  822.  n = 1073741854 -> m = 30
  823.  n = 1073741886 -> m = 62
  824.  n = 1073741918 -> m = 94
  825.  n = 1073741950 -> m = 126
  826.  n = 2147483551 -> m = -97
  827.  n = 2147483583 -> m = -65
  828.  n = 2147483615 -> m = -33
  829.  n = 2147483647 -> m = -1
  830. ------------------------------------+---+---+---+---+---+----
  831. move.l #n,m? -> moveq  #n,ds        | Y | Y | ? | ? | ? | 2
  832.         move.l ds,m?        |    |   |    |   |    |
  833. ------------------------------------+---+---+---+---+---+----
  834.  -128 <= n <= 127
  835. ------------------------------------+---+---+---+---+---+----
  836. move.l (ax),ay -> move.x ([ax],n),dz| - | - | ? | ? | ? | ?
  837. move.x n(ay),dz             |    |   |    |   |    |
  838. ------------------------------------+---+---+---+---+---+----
  839. move.l (ax),ay -> move.x ([ax]),dz  | - | - | ? | ? | ? | ?
  840. move.x (ay),dz                |    |   |    |   |    |
  841. ------------------------------------+---+---+---+---+---+----
  842. move.l (bd.x,ax),dy ->            | - | - | ? | ? | ? | ?
  843.              move.l bd.x,dy |    |   |    |   |    |
  844. ------------------------------------+---+---+---+---+---+----
  845. move.l (n.w,ax),dy ->            | - | - | ? | ? | ? | ?
  846.             move.l n(ax),dy |    |   |    |   |    |
  847. ------------------------------------+---+---+---+---+---+----
  848. move.l (sp),(n,sp) -> rtd #n        | - | - | ? | ? | ? | ?
  849. lea (n,sp),sp                |    |   |    |   |    |
  850. rts                    |    |   |    |   |    |
  851. ------------------------------------+---+---+---+---+---+----
  852. move.l (sp),0(dx,sp) -> rtd dx        | - | Y | ? | ? | ? | 6
  853. lea 0(dx,sp),sp                |    |   |    |   |    |
  854. rts                    |    |   |    |   |    |
  855. ------------------------------------+---+---+---+---+---+----
  856. move.l 12(ax),12(ay) -> move16        | - | - | - | - | ? | ?
  857. move.l 8(ax),8(ay)    (ax)+,(ay)+ |    |   |    |   |    |
  858. move.l 4(ax),4(ay)            |    |   |    |   |    |
  859. move.l (ax)+,(ay)+            |    |   |    |   |    |
  860. ------------------------------------+---+---+---+---+---+----
  861. move.l ax,-(sp) -> link ax,#n        | Y | Y | ? | ? | ? | 4
  862. move.l sp,ax                |    |   |    |   |    |
  863. add.w #n,sp                |    |   |    |   |    |
  864. ------------------------------------+---+---+---+---+---+----
  865.  -32767 <= n <= 32767
  866. ------------------------------------+---+---+---+---+---+----
  867. move.l ax,-(sp) -> pea -n(ax)        | Y | Y | ? | ? | ? | 0/4
  868. sub*.l #n,(sp)                |    |   |    |   |    |
  869. ------------------------------------+---+---+---+---+---+----
  870. move.l ax,-(sp) -> pea n(ax)        | Y | Y | ? | ? | ? | 0/4
  871. add*.l #n,(sp)                |    |   |    |   |    |
  872. ------------------------------------+---+---+---+---+---+----
  873. move.l ax,az -> lea n(ax.l*4),az    | - | - | ? | ? | ? | ?
  874. asl.l #2,az                |    |   |    |   |    |
  875. add.x #n,az                |    |   |    |   |    |
  876. ------------------------------------+---+---+---+---+---+----
  877.  az=n+4*ax, -128<=n<=127
  878. ------------------------------------+---+---+---+---+---+----
  879. move.l ax,az -> lea n(ax.l*8),az    | - | - | ? | ? | ? | ?
  880. asl.l #3,az                |    |   |    |   |    |
  881. add.x #n,az                |    |   |    |   |    |
  882. ------------------------------------+---+---+---+---+---+----
  883.  az=n+8*ax, -32767<=n<=32767
  884. ------------------------------------+---+---+---+---+---+----
  885. move.l ax,sp -> unlk ax         | Y | Y | ? | ? | ? | 2
  886. move.l (sp)+,ax             |    |   |    |   |    |
  887. ------------------------------------+---+---+---+---+---+----
  888. move.l ay,az -> lea n(ax,ay.l*4),az | - | - | ? | ? | ? | ?
  889. asl.l #2,az                |    |   |    |   |    |
  890. add.l ax,az                |    |   |    |   |    |
  891. add.x #n,az                |    |   |    |   |    |
  892. ------------------------------------+---+---+---+---+---+----
  893.  az=n+ax+4*ay, -32767<=n<=32767
  894. ------------------------------------+---+---+---+---+---+----
  895. move.l ay,az -> lea n(ax,ay.l*8),az | - | - | ? | ? | ? | ?
  896. asl.l #3,az                |    |   |    |   |    |
  897. add.l ax,az                |    |   |    |   |    |
  898. add.x #n,az                |    |   |    |   |    |
  899. ------------------------------------+---+---+---+---+---+----
  900.  az=n+ax+8*ay, -32767<=n<=32767
  901. ------------------------------------+---+---+---+---+---+----
  902. move.w #x,mn   -> move.l #xy,mn     | Y | Y | ? | ? | ? | 2/4/6
  903. move.w #y,mn+2                |    |   |    |   |    |
  904. ------------------------------------+---+---+---+---+---+----
  905.  best if mn is longword aligned
  906. ------------------------------------+---+---+---+---+---+----
  907. move.x #0,ax -> sub.l ax,ax        | Y | Y | ? | ? | ? | 2/4
  908. ------------------------------------+---+---+---+---+---+----
  909. move.x #n,ax -> lea n,ax        | Y | Y | ? | ? | ? | 0
  910. ------------------------------------+---+---+---+---+---+----
  911.  n <> 0
  912. ------------------------------------+---+---+---+---+---+----
  913. move.x (rx,ay),az -> move.x ay,az   | Y | Y | ? | ? | ? | 0
  914.              add.x rx,az    |    |   |    |   |    |
  915. ------------------------------------+---+---+---+---+---+----
  916. move.x ax,ay -> lea n(ax),ay        | Y | Y | ? | ? | ? | 2/4
  917. add.x #n,ay                |    |   |    |   |    |
  918. ------------------------------------+---+---+---+---+---+----
  919.  -32767 <= n <= 32767
  920. ------------------------------------+---+---+---+---+---+----
  921. move.x ax,az -> lea -n(ax,ay),az    | Y | Y | ? | ? | ? | 2
  922. sub.x #n,az                |    |   |    |   |    |
  923. add.x ay,az                |    |   |    |   |    |
  924. ------------------------------------+---+---+---+---+---+----
  925.  az=n+ax+ay, n<=32767
  926. ------------------------------------+---+---+---+---+---+----
  927. move.x ax,az -> lea n(ax,ay),az     | Y | Y | ? | ? | ? | 2
  928. add.x #n,az                |    |   |    |   |    |
  929. add.x ay,az                |    |   |    |   |    |
  930. ------------------------------------+---+---+---+---+---+----
  931.  az=n+ax+ay, n<=32767
  932. ------------------------------------+---+---+---+---+---+----
  933. movem.l (ax)+,registers         | * | * | ? | ? | Y | *
  934.          -> move.l (ax)+,ry |    |   |    |   |    |
  935.                for each reg |    |   |    |   |    |
  936. ------------------------------------+---+---+---+---+---+----
  937. movem.w *,dx -> move.w *,dx        | Y | Y | ? | ? | ? | 0
  938.         ext.l dx        |    |   |    |   |    |
  939. ------------------------------------+---+---+---+---+---+----
  940. movem.x *,@ -> move.x *,@        | Y | Y | ? | ? | ? | 2
  941.                     |    |   |    |   |    |
  942. ------------------------------------+---+---+---+---+---+----
  943.  @ = a single register, not (@=dx & .x=.w)
  944. ------------------------------------+---+---+---+---+---+----
  945. movem.x @,* -> move.x @,*        | Y | Y | ? | ? | ? | 2
  946.                     |    |   |    |   |    |
  947. ------------------------------------+---+---+---+---+---+----
  948.  @ = a single register, status flags are wrong
  949. ------------------------------------+---+---+---+---+---+----
  950. moveq #n,az -> lea n(ax,ay.l*2),az  | - | - | ? | ? | ? | ?
  951. add.x ay,az                |    |   |    |   |    |
  952. add.x ax,az                |    |   |    |   |    |
  953. add.x ay,az                |    |   |    |   |    |
  954. ------------------------------------+---+---+---+---+---+----
  955.  az=n+ax+2*ay, -128<=n<=127
  956. ------------------------------------+---+---+---+---+---+----
  957. mul*.l #1,dx -> (nothing)           | ! | ! | Y | Y | Y | 6
  958. ------------------------------------+---+---+---+---+---+----
  959.  delete
  960. ------------------------------------+---+---+---+---+---+----
  961. mul*.l #10,dx -> add.l dx,dx        | ! | ! | ? | ? | ? | -2
  962.          move.l dx,ds        |    |   |    |   |    |
  963.          asl.l #2,dx        |    |   |    |   |    |
  964.          add.l ds,dx        |    |   |    |   |    |
  965. ------------------------------------+---+---+---+---+---+----
  966. mul*.l #12,dx -> asl.l #2,dx        | ! | ! | ? | ? | ? | -2
  967.          move.l dx,ds        |    |   |    |   |    |
  968.          add.l dx,dx        |    |   |    |   |    |
  969.          add.l ds,dx        |    |   |    |   |    |
  970. ------------------------------------+---+---+---+---+---+----
  971. mul*.l #2,dx -> add.l dx,dx        | ! | ! | ? | ? | ? | 4
  972. ------------------------------------+---+---+---+---+---+----
  973. mul*.l #3,dx -> move.l dx,ds        | ! | ! | ? | ? | ? | 0
  974.         add.l dx,dx        |    |   |    |   |    |
  975.         add.l ds,dx        |    |   |    |   |    |
  976. ------------------------------------+---+---+---+---+---+----
  977. mul*.l #5,dx -> move.l dx,ds        | ! | ! | ? | ? | ? | 0
  978.         asl.l #2,dx        |    |   |    |   |    |
  979.         add.l ds,dx        |    |   |    |   |    |
  980. ------------------------------------+---+---+---+---+---+----
  981. mul*.l #6,dx -> add.l dx,dx        | ! | ! | ? | ? | ? | -2
  982.         move.l dx,ds        |    |   |    |   |    |
  983.         add.l dx,dx        |    |   |    |   |    |
  984.         add.l ds,dx        |    |   |    |   |    |
  985. ------------------------------------+---+---+---+---+---+----
  986. mul*.l #7,dx -> move.l dx,ds        | ! | ! | ? | ? | ? | 0
  987.         asl.l #3,dx        |    |   |    |   |    |
  988.         sub.l ds,dx        |    |   |    |   |    |
  989. ------------------------------------+---+---+---+---+---+----
  990. mul*.l #9,dx -> move.l dx,ds        | ! | ! | ? | ? | ? | 0
  991.         asl.l #3,dx        |    |   |    |   |    |
  992.         add.l ds,dx        |    |   |    |   |    |
  993. ------------------------------------+---+---+---+---+---+----
  994. mul*.l #n,dx -> moveq #m,ds         | ! | ! | ? | ? | ? | 2
  995.         asl.l ds,dx        |    |   |    |   |    |
  996. ------------------------------------+---+---+---+---+---+----
  997.  n is 2^m, 8<m<14
  998. ------------------------------------+---+---+---+---+---+----
  999. muls.l #0,dx -> moveq #0,dx        | ! | ! | ? | ? | ? | 4
  1000. ------------------------------------+---+---+---+---+---+----
  1001. muls.l #n,dx -> asl.l #m,dx        | ! | ! | ? | ? | ? | 4
  1002. ------------------------------------+---+---+---+---+---+----
  1003.  n is 2^m, 1 <= m <= 8
  1004. ------------------------------------+---+---+---+---+---+----
  1005. muls.w #0,dx -> moveq #0,dx        | Y | Y | ? | ? | ? | 2
  1006. ------------------------------------+---+---+---+---+---+----
  1007. muls.w #1,dx -> ext.l dx        | Y | Y | ? | ? | ? | 2
  1008. ------------------------------------+---+---+---+---+---+----
  1009. muls.w #10,dx -> ext.l dx        | Y | Y | ? | ? | ? | -6
  1010.          add.l dx,dx        |    |   |    |   |    |
  1011.          move.l dx,ds        |    |   |    |   |    |
  1012.          asl.l #2,dx        |    |   |    |   |    |
  1013.          add.l ds,dx        |    |   |    |   |    |
  1014. ------------------------------------+---+---+---+---+---+----
  1015. muls.w #11,dx -> ext.l dx        | Y | Y | ? | ? | ? | -8
  1016.          move.l dx,ds        |    |   |    |   |    |
  1017.          add.l dx,dx        |    |   |    |   |    |
  1018.          add.l dx,ds        |    |   |    |   |    |
  1019.          asl.l #3,dx        |    |   |    |   |    |
  1020.          add.l ds,dx        |    |   |    |   |    |
  1021. ------------------------------------+---+---+---+---+---+----
  1022. muls.w #12,dx -> ext.l dx        | Y | Y | ? | ? | ? | -6
  1023.          asl.l #2,dx        |    |   |    |   |    |
  1024.          move.l dx,ds        |    |   |    |   |    |
  1025.          add.l dx,dx        |    |   |    |   |    |
  1026.          add.l ds,dx        |    |   |    |   |    |
  1027. ------------------------------------+---+---+---+---+---+----
  1028. muls.w #2,dx -> ext.l dx        | Y | Y | ? | ? | ? | 0
  1029.         add.l dx,dx        |    |   |    |   |    |
  1030. ------------------------------------+---+---+---+---+---+----
  1031. muls.w #3,dx -> ext.l dx        | Y | Y | ? | ? | ? | -4
  1032.         move.l dx,ds        |    |   |    |   |    |
  1033.         add.l dx,dx        |    |   |    |   |    |
  1034.         add.l ds,dx        |    |   |    |   |    |
  1035. ------------------------------------+---+---+---+---+---+----
  1036. muls.w #5,dx -> ext.l dx        | Y | Y | ? | ? | ? | -4
  1037.         move.l dx,ds        |    |   |    |   |    |
  1038.         asl.l #2,dx        |    |   |    |   |    |
  1039.         add.l ds,dx        |    |   |    |   |    |
  1040. ------------------------------------+---+---+---+---+---+----
  1041. muls.w #6,dx -> ext.l dx        | Y | Y | ? | ? | ? | -6
  1042.         add.l dx,dx        |    |   |    |   |    |
  1043.         move.l dx,ds        |    |   |    |   |    |
  1044.         add.l ds,dx        |    |   |    |   |    |
  1045.         add.l ds,dx        |    |   |    |   |    |
  1046. ------------------------------------+---+---+---+---+---+----
  1047. muls.w #7,dx -> ext.l dx        | Y | Y | ? | ? | ? | -4
  1048.         move.l dx,ds        |    |   |    |   |    |
  1049.         asl.l #3,dx        |    |   |    |   |    |
  1050.         sub.l ds,dx        |    |   |    |   |    |
  1051. ------------------------------------+---+---+---+---+---+----
  1052. muls.w #9,dx -> ext.l dx        | Y | Y | ? | ? | ? | -4
  1053.         move.l dx,ds        |    |   |    |   |    |
  1054.         asl.l #3,dx        |    |   |    |   |    |
  1055.         add.l ds,dx        |    |   |    |   |    |
  1056. ------------------------------------+---+---+---+---+---+----
  1057. muls.w #n,dx -> ext.l dx        | Y | Y | ? | ? | ? | 0
  1058.         asl.l #m,dx        |    |   |    |   |    |
  1059. ------------------------------------+---+---+---+---+---+----
  1060.  n is 2^m, 1 <= m <= 8
  1061. ------------------------------------+---+---+---+---+---+----
  1062. muls.w #n,dx -> moveq #m,ds        | Y | Y | ? | ? | ? | -2
  1063.         ext.l dx        |    |   |    |   |    |
  1064.         asl.l ds,dx        |    |   |    |   |    |
  1065. ------------------------------------+---+---+---+---+---+----
  1066.  n is 2^m, 8<m<14
  1067. ------------------------------------+---+---+---+---+---+----
  1068. muls.w #n,dx -> swap dx            | Y | Y | ? | ? | ? | -2
  1069.         clr.w dx        |    |   |    |   |    |
  1070.         asr.l #(16-m),dx    |    |   |    |   |    |
  1071. ------------------------------------+---+---+---+---+---+----
  1072.  n is 2^m, 8 <= m <= 15
  1073. ------------------------------------+---+---+---+---+---+----
  1074. mulu.l #0,dx -> moveq #0,dx        | ! | ! | ? | ? | ? | 4
  1075. ------------------------------------+---+---+---+---+---+----
  1076. mulu.l #n,dx -> lsl.l #m,dx        | ! | ! | ? | ? | ? | 4
  1077. ------------------------------------+---+---+---+---+---+----
  1078.  n is 2^m, 1 <= m <= ?
  1079. ------------------------------------+---+---+---+---+---+----
  1080. mulu.w #0,dx -> moveq #0,dx        | Y | Y | ? | ? | ? | 2
  1081. ------------------------------------+---+---+---+---+---+----
  1082. mulu.w #1,dx -> swap dx            | Y | Y | ? | ? | ? | -2
  1083.         clr.w dx        |    |   |    |   |    |
  1084.         swap dx            |    |   |    |   |    |
  1085. ------------------------------------+---+---+---+---+---+----
  1086. mulu.w #12,dx -> swap dx        | Y | Y | ? | ? | ? | -10
  1087.          clr.w dx        |    |   |    |   |    |
  1088.          swap dx        |    |   |    |   |    |
  1089.          asl.l #2,dx        |    |   |    |   |    |
  1090.          move.l dx,ds        |    |   |    |   |    |
  1091.          add.l dx,dx        |    |   |    |   |    |
  1092.          add.l ds,dx        |    |   |    |   |    |
  1093. ------------------------------------+---+---+---+---+---+----
  1094. mulu.w #2,dx -> swap dx         | Y | Y | ? | ? | ? | -4
  1095.         clr.w dx        |    |   |    |   |    |
  1096.         swap dx         |    |   |    |   |    |
  1097.         add.l dx,dx        |    |   |    |   |    |
  1098. ------------------------------------+---+---+---+---+---+----
  1099. mulu.w #3,dx -> swap dx         | Y | Y | ? | ? | ? | -8
  1100.         clr.w dx        |    |   |    |   |    |
  1101.         swap dx         |    |   |    |   |    |
  1102.         move.l dx,ds        |    |   |    |   |    |
  1103.         add.l dx,dx        |    |   |    |   |    |
  1104.         add.l ds,dx        |    |   |    |   |    |
  1105. ------------------------------------+---+---+---+---+---+----
  1106. mulu.w #5,dx -> swap dx         | Y | Y | ? | ? | ? | -8
  1107.         clr.w dx        |    |   |    |   |    |
  1108.         swap dx         |    |   |    |   |    |
  1109.         move.l dx,ds        |    |   |    |   |    |
  1110.         asl.l #2,dx        |    |   |    |   |    |
  1111.         add.l ds,dx        |    |   |    |   |    |
  1112. ------------------------------------+---+---+---+---+---+----
  1113. mulu.w #6,dx -> swap dx         | Y | Y | ? | ? | ? | -10
  1114.         clr.w dx        |    |   |    |   |    |
  1115.         swap dx         |    |   |    |   |    |
  1116.         add.l dx,dx        |    |   |    |   |    |
  1117.         move.l dx,ds        |    |   |    |   |    |
  1118.         add.l ds,dx        |    |   |    |   |    |
  1119.         add.l ds,dx        |    |   |    |   |    |
  1120. ------------------------------------+---+---+---+---+---+----
  1121. mulu.w #7,dx -> swap dx         | Y | Y | ? | ? | ? | -8
  1122.         clr.w dx        |    |   |    |   |    |
  1123.         swap dx         |    |   |    |   |    |
  1124.         move.l dx,ds        |    |   |    |   |    |
  1125.         asl.l #3,dx        |    |   |    |   |    |
  1126.         sub.l ds,dx        |    |   |    |   |    |
  1127. ------------------------------------+---+---+---+---+---+----
  1128. mulu.w #9,dx -> swap dx         | Y | Y | ? | ? | ? | -8
  1129.         clr.w dx        |    |   |    |   |    |
  1130.         swap dx         |    |   |    |   |    |
  1131.         move.l dx,ds        |    |   |    |   |    |
  1132.         asl.l #3,dx        |    |   |    |   |    |
  1133.         add.l ds,dx        |    |   |    |   |    |
  1134. ------------------------------------+---+---+---+---+---+----
  1135. mulu.w #n,dx -> swap dx            | Y | Y | ? | ? | ? | -4
  1136.         clr.w dx        |    |   |    |   |    |
  1137.         swap dx            |    |   |    |   |    |
  1138.         lsl.l #m,dx        |    |   |    |   |    |
  1139. ------------------------------------+---+---+---+---+---+----
  1140.  n is 2^m, 1 <= m <= 8
  1141. ------------------------------------+---+---+---+---+---+----
  1142. mulu.w #n,dx -> swap dx            | Y | Y | ? | ? | ? | -2
  1143.         clr.w dx        |    |   |    |   |    |
  1144.         lsr.l #(16-m),dx    |    |   |    |   |    |
  1145. ------------------------------------+---+---+---+---+---+----
  1146.  n is 2^m, 8 <= m <= 15
  1147. ------------------------------------+---+---+---+---+---+----
  1148. neg.x dx    -> add.x dx,dy        | Y | Y | Y | ? | ? | 2
  1149. sub.x dx,dy                |    |   |    |   |    |
  1150. ------------------------------------+---+---+---+---+---+----
  1151.  dx is trashed
  1152. ------------------------------------+---+---+---+---+---+----
  1153. neg.x dx    -> eor.x #n-1,dx        | Y | Y | ? | ? | ? | 2
  1154. add.x #n,dx                |    |   |    |   |    |
  1155. ------------------------------------+---+---+---+---+---+----
  1156.  n is 2^m, dx<n
  1157. ------------------------------------+---+---+---+---+---+----
  1158. neg.x dx    -> sub.x dx,dy        | Y | Y | Y | ? | ? | 2
  1159. add.x dx,dy                |    |   |    |   |    |
  1160. ------------------------------------+---+---+---+---+---+----
  1161.  dx is trashed
  1162. ------------------------------------+---+---+---+---+---+----
  1163. nop -> (nothing)            | Y | Y | ? | ? | ? | 2
  1164. ------------------------------------+---+---+---+---+---+----
  1165.  remove nops
  1166. ------------------------------------+---+---+---+---+---+----
  1167. or.l #n,dx -> bset.l #b,dx        | Y | Y | ? | ? | ? | 2
  1168. ------------------------------------+---+---+---+---+---+----
  1169.  n = 2^b (only 1 bit set)
  1170. ------------------------------------+---+---+---+---+---+----
  1171. sub*.x #0,dx -> tst.x dx        | Y | Y | ? | ? | ? | 2/4
  1172. ------------------------------------+---+---+---+---+---+----
  1173. sub.x #n,* -> addq.x #-n,*        | Y | Y | ? | ? | ? | 2/4
  1174. ------------------------------------+---+---+---+---+---+----
  1175.  -8 <= n <= -1
  1176. ------------------------------------+---+---+---+---+---+----
  1177. sub.x #n,* -> subq.x #n,*        | Y | Y | ? | ? | ? | 2/4
  1178. ------------------------------------+---+---+---+---+---+----
  1179.  if 1 <= n <= 8
  1180. ------------------------------------+---+---+---+---+---+----
  1181. sub.x #n,ax -> lea -n(ax),ax        | Y | Y | ? | ? | ? | 0/2
  1182. ------------------------------------+---+---+---+---+---+----
  1183.  -32767 <= n <= -9, 9 <= n <= 32767
  1184. ------------------------------------+---+---+---+---+---+----
  1185. subq.l #n,ax -> subq.w #n,ax        | Y | Y | ? | ? | ? | 0
  1186. ------------------------------------+---+---+---+---+---+----
  1187. subq.w #1,dx -> db<cc> dx,??        | y | y | ? | ? | ? | -2
  1188. b<cc> ??    b<cc> ??        |    |   |    |   |    |
  1189. ------------------------------------+---+---+---+---+---+----
  1190.  if dx=0 then will be slower
  1191. ------------------------------------+---+---+---+---+---+----
  1192. subq.w #1,dx -> dbf dx,??        | Y | Y | ? | ? | ? | -2
  1193. bra ??        bra ??            |    |   |    |   |    |
  1194. ------------------------------------+---+---+---+---+---+----
  1195.  if dx=0 then will be slower
  1196. ------------------------------------+---+---+---+---+---+----
  1197. tst.w dx -> dbra dx,??            | y | y | ? | ? | ? | 2
  1198. bne ??                    |    |   |    |   |    |
  1199. ------------------------------------+---+---+---+---+---+----
  1200.  dx will be trashed
  1201. ------------------------------------+---+---+---+---+---+----
  1202.  
  1203.  
  1204. ---------------------------------------------------------------------------
  1205.               H I N T S   &   T I P S
  1206. ---------------------------------------------------------------------------
  1207.  
  1208.  
  1209. This new section is for stuff that cannot be included in the above tables.
  1210. This can include pipelining optimizations and other stuff.
  1211.  
  1212. 020+    Sequential memory accesses can cause pipeline stalls, so try and
  1213.     rearrange code so memory accesses do not immediately follow each
  1214.     other.  The same problem occurs if an address register updated
  1215.     in one line is accessed in the next line.
  1216.  
  1217. ALL    Include small routines as macros, because inline routines will
  1218.     be much faster, and in extreme cases smaller.
  1219.  
  1220. ALL    If a subroutine is only called from one position, either move
  1221.     it inline, or only use jmp/bra commands.
  1222.  
  1223.  
  1224. ---------------------------------------------------------------------------
  1225.                 C O N C L U S I O N
  1226. ---------------------------------------------------------------------------
  1227.  
  1228.  
  1229. There are the optimizations i've come up with so far.  If you could check
  1230. what i've done, and report any errors, that would make this list better.  I
  1231. only have so much time to spend on this, and many hands make light work.
  1232. Also, stats (and more optimizations) for 68020+ CPU's would be welcomed.
  1233. Currently this list is only for simple peephole optimization stuff, but I
  1234. will hopefully get around to more extensive optimizations.  Pipeline
  1235. optimization is on the way, so look out.  Any info on the 68020+ pipelines
  1236. would be appreciated.
  1237.  
  1238. Optimizations with ?question-marks? in the boxes next to them, I do not
  1239. have the data to check yet.
  1240.  
  1241. The latest version of the asp68k archive is available by anonymous ftp from
  1242. ftp.mq.edu.au in the /home/mglew/ directory or by calling Technophilia BBS
  1243. on +61 2 807 3563 (or (02) 807 3563 in Australia).
  1244.  
  1245.  
  1246. ===========================================================================
  1247. EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF
  1248. ===========================================================================
  1249.